package com.itheima.aop;

import com.itheima.entity.Result;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;

public class Aop {
    @Around("AopPointCut.pt()")
    public Object aroundDetect(ProceedingJoinPoint pjp) {
        Object proceed = null;
        Object[] args = pjp.getArgs();
        Object name = args[3];
        Object code = args[4];
        try {
            if (name == null) {
                return new Result(false, "项目名称不能为空");
            }
            if (code == null) {
                return new Result(false, "项目编码不能为空");
            }
              proceed = pjp.proceed();

        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return proceed;
    }
}
